home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 22 / Amiga Format AFCD22 (Jan 1998, Issue 106).iso / -seriously_amiga- / shareware / programming / other / gui4cli / dir / dir.xpack < prev   
Text File  |  1997-11-17  |  6KB  |  206 lines

  1. G4C
  2.  
  3. ;
  4. ; April '97 by Brian Jones
  5. ; XPK packing and unpacking gui for D. Keletsekis' Dir.gc
  6. ;
  7. ; This gui needs xpack (from the XPK distribution in the c drawer)
  8. ; in C:
  9. ; Passwords are supported but not well trapped, if something won't
  10. ; unpack it probably needs a password (but it won't tell you).
  11. ; Also, not all xpk sub-libraries support password encoding so
  12. ; if you are trying to apply a password and it won't work the 
  13. ; sub-library probably can't use one.
  14. ;
  15.  
  16. WINBIG -1 11 486 174   "Choose Packer -- Reload to get new files"
  17. WinType 11110001
  18. nofontsense
  19. varpath dir.gc
  20.  
  21. xOnLoad
  22. ;run 'Sys:Utilities/IP'                   ;only if you run k-p koljonen's
  23. xid = $$lv.id                             ;transparent xpk handler
  24. xdir = $$lv.dir
  25. gosub dir.xpack startup1                  ;load the listviews
  26. gosub dir.xpack startup
  27. run 'resident c:xpack pure add'
  28.  
  29. xOnReload                       
  30. xid = $$lv.id
  31. xdir = $$LV.DIR
  32. gosub dir.xpack startup1           
  33. gosub dir.xpack startup
  34.  
  35. xOnClose
  36. GuiQuit dir.xpack
  37.  
  38. xOnQuit                           ;cleanup
  39. run 'resident xpack remove'
  40. ;run 'Sys:Utilities/IP'           ;needed only if you use IP (see above)
  41.  
  42. ;The Listviews
  43. ;-------------------------------------------------------------
  44. XLISTVIEW 174 19 160 129  "" rawcmprsr "LIBS:Compressors" 0 DIR   ;see note
  45. GadID 1                                                           ;below
  46.  
  47. XLISTVIEW 5 16 150 146    "" cmprsr "" 0 TXT
  48. GadID 2
  49. update dir.xpack 4 $cmprsr
  50.  
  51. XLISTVIEW 161 32 320 131  "" xfile "" 10 MULTI
  52. GadID 3
  53.  
  54. ;The Gadgets
  55. ;------------------------------------------------------
  56. TEXT 3 1 150 13  "RAKE" 100 BOX
  57. GadID 4
  58.  
  59. XHSLIDER 54 159 64 12  "Mode?" xmode 0 100 100 "%ld%%"
  60. GadID 5
  61.  
  62. XCYCLER 161 1 80 13  "" xchoice
  63. GadID 6
  64. CStr Pack pack
  65. CStr Unpack unpack
  66. gosub dir.xpack makegui
  67.  
  68. XBUTTON 404 1 77 13  "GO!"
  69. GadID 7
  70. lvuse dir.xpack 3
  71. lvgo #0
  72. xfile = $$lv.rec
  73. xcount = 0
  74. if $xchoice = pack
  75.    appvar cmprsr '.'
  76.    appvar cmprsr $xmode
  77. endif
  78. if $xpass = ""
  79.     psswrd = ""
  80. else
  81.     psswrd = PASSWORD
  82. endif
  83. guiwindow dir.xpack wait
  84. Launch 1 'xpack $xfile $xmthd $cmprsr $psswrd $xpass ALL QUIET'
  85.  
  86. XBUTTON 324 1 77 13        "CANCEL"
  87. GadID 8
  88. guiClose dir.xpack
  89.  
  90. XBUTTON 244 1 77 13        "Reload"
  91. GadID 9
  92. xid  = $$lv.id           
  93. xdir = $$LV.DIR
  94. lvuse dir.xpack 3
  95. lvclear
  96. gosub dir.xpack startup
  97.  
  98. GAUGE 162 158 319 13  IN RIDGE 2 0 0
  99. GadID 10 
  100.  
  101. XTEXTIN 244 16 157 14  "Password " xpass "" 100
  102. GadID 11
  103.  
  104. ;-----------------------------------------------------------
  105. xOnReturn 1                 ;continuation of processing if there is more     
  106. lvuse dir.xpack 3           ;than one file.
  107. counter xcount inc 1
  108. if $xcount < $$lv.total     ; not the end of the lv
  109.    xpercent == $xcount * 100
  110.    xpercent == $xpercent / $xfilecount
  111.    update dir.xpack 10 $xpercent
  112.    lvgo next  ;#$xcount
  113.    xfile = $$lv.rec
  114.    Launch 1 'xpack $xfile $xmthd $cmprsr $psswrd $xpass ALL QUIET'
  115. else
  116.    guiwindow dir.xpack resume
  117.    update dir.xpack 10 0
  118.    setwintitle dir.xpack 'Finished - Choose new files or quit'
  119.    lvuse dir.gc $xid
  120.    lvdir refresh
  121. endif
  122.  
  123. ;--------------------------------------------------------------
  124. xroutine startup                ;setup of the list of files to be packed
  125. xfilecount = 0            ; or unpacked
  126. lvuse dir.gc $xid
  127. lvmulti first
  128. if $lv_file = ""
  129.    ezreq "How's about choosing\nsome files first ?" 'Oh yeah..' ""
  130.    stop
  131. endif
  132. while $lv_file > ""
  133.   extract lv_file ext tempinf
  134.     if $tempinf != ".info"         ;;this is a filter for .info files so
  135.       counter xfilecount inc 1      ;they won't be packed and become
  136.       lvuse dir.xpack 3             ;unreadable
  137.       lvadd $lv_file
  138.       lvuse dir.gc $xid
  139.     endif
  140.   lvmulti next
  141. endwhile
  142. setgad dir.xpack 1 HIDE
  143. guiopen dir.xpack
  144.  
  145. xRoutine startup1               ;set up of the list of xpk sub-libraries.
  146. xchoice = pack                  ;this expects a normal xpk installation
  147. xmthd = METHOD                  ;(Libs:Compressors) if not, change the 
  148. cmprsr = RAKE                   ;place that listview 1 looks for the
  149. xmode = 100                     ;sub-libraries (see listviews section
  150. psswrd = ""                     ;above) 
  151. xpass = ""
  152. lvuse dir.xpack 2
  153. lvclear
  154. LVuse dir.xpack 1               
  155. LVdir all                       
  156. lvmulti first                    
  157. while $rawcmprsr > ""             
  158.    tempcmp = $$LV.REC
  159.    cutvar tempcmp CUT CHAR 3 dummy1
  160.    cutvar tempcmp CUT CHAR -8 dummy2
  161.    lvuse dir.xpack 2
  162.    lvadd $tempcmp
  163.    lvuse dir.xpack 1
  164.    lvmulti next
  165. endwhile
  166.  
  167. xroutine makegui                   ;this could be easier if I put the
  168. if $xchoice = pack                 ;xpk libraries list on the right
  169.    setgad dir.xpack 2 show         ;instead of the left but I like
  170.    setgad dir.xpack 4 show         ;it better that way
  171.    setgad dir.xpack 5 show
  172.    changearg dir.xpack 3 0 161
  173.    changearg dir.xpack 6 0 161
  174.    changearg dir.xpack 7 0 404
  175.    changearg dir.xpack 8 0 324
  176.    changearg dir.xpack 9 0 244
  177.    changearg dir.xpack 10 0 162
  178.    changearg dir.xpack 11 0 244
  179.    changegad dir.xpack 0 -1 11 486 174 ""
  180.    setwintitle dir.xpack "Choose Packer -- Reload to get new files"
  181.    xmthd = METHOD                 ;reset some stuff now that we're back in
  182.    xmode = 100                    ;pack mode
  183.    update dir.xpack 5 100
  184.    if $cmprsr = ""
  185.       cmprsr = RAKE
  186.    endif
  187. else
  188.    setgad dir.xpack 2 hide
  189.    setgad dir.xpack 4 hide
  190.    setgad dir.xpack 5 hide
  191.    changearg dir.xpack 3 0 2
  192.    changearg dir.xpack 6 0 2
  193.    changearg dir.xpack 7 0 245
  194.    changearg dir.xpack 8 0 165
  195.    changearg dir.xpack 9 0 85
  196.    changearg dir.xpack 10 0 4
  197.    changearg dir.xpack 11 0 85
  198.    changegad dir.xpack 0 -1 11 326 174 ""
  199.    setwintitle dir.xpack "Unpack -- Reload for new files"
  200.    xmthd = ""           ;these are not needed in decompress mode
  201.    cmprsr = ""          ;
  202. endif
  203. redraw dir.xpack
  204.  
  205.  
  206.